home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
027a
/
proplus.zip
/
SAMPLE.PRG
< prev
next >
Wrap
Text File
|
1991-03-14
|
15KB
|
363 lines
* WELCOME to the Protection Plus sample program. This program is heavily
* documented so you can get the feel of how this system works. A copy of
* same source is provided in sample1.prg minus the comments. This is to
* you see just how much code is added to your existing application.
* Keep in mind that this demo utilizes quite a few of the functions, so
* your application might not need all of it. This sample, does not make
* reference to any copy protection. It is only limited as a demo as
* generated by the PROPLUS host program.
* You don't like the way that this demo works, you say? Well, you are
* more than welcome to change it around to flow exactly how you would like
* it! Read through all of the comments and play around with the macro
* entry. This is where you can type in function names and parameters and
* view the results. Remember that if a mistake is made in typing, a runtime
* error will result. I recommend that you print out the ASCII manual and
* try out the functions right from there. Enjoy!
* The following variable MUST be defined PUBLIC in your program and the
* contents of it should contain the name of the control file minus the
* extention.
PUBLIC pp_cfile, demo_ver
PRIVATE password, get_code, choice, exe_limit
pp_cfile="SAMPLE"
* Strings are stored in the control file that tell various information
* about the user and application. A list of variables can be found in the
* documention. The following function call, pp_getvar, initializes these
* variables PUBLIC for your use. If you do not use them, do not call this
* function.
if !pp_getvar()
? "Error reading control file... Call technical support!"
?
cancel
endif
* We can't let the program run if it has come time to expire now, can we?
* The following code determines if the product has expired by date or
* execution counts? The date needs to be checked to make sure that no
* tampering has been done, but this is done after the password screen
* so that a code entry function can be used to bypass the test. This is
* necessary if the date was accicentally screwed-up and the program stored
* the last date and time used as the screwed-up date
* 2) has the date been tampered with? (date<last used date?)
* NOTE that if it has expired (by date) it is important to perform a
* pp_upddate() (described later) so that the combination of the date
* checking and the expiration date checking prohibit unauthorized use
* of your application
if pp_expired()
? "Sorry, but the demo for this product has expired... Please call and"
? "order from C.R.S. at 614-676-2771"
?
pp_upddate()
cancel
endif
* The followng checks the date and the time to make sure that the last
* date and time used is less than the current date and time. If not, the
* user is trying to "back up" the computer clock in order to gain more time
* from your running demo or payment package. This check is only valid IF
* the current expire type is NOT "None" (which means unlocked). The test is
* run once. If it fails, the user can enter the new date and time. If it
* still fails then he is given an option to enter a code number. This is
* just in case the user accidentally forwards his DOS date to an advanced
* value and runs the program and then sets it back correctly. If you do
* not follow this two step check as shown below, the user will NEVER be able
* to set his clock back to the right date. Upon entering the correct code
* number, the current DOS date and time is saved into the last used date and
* time field in the control file. Since the RUN command is highly frowned
* upon, it is recommended to use another method of achieving this result,
* such as a DOS gateway function like OVERLAY() by Gambit Software or your
* own C function.
if !pp_valdate() .AND. pp_exptype()#"N"
clear
curr_date=date()
curr_time=time()
@ 2,0 say "Please set the date and time correctly:"
?
?
run date
@ 7,0 say ""
run time
endif
* The description for pp_cenum(), propl0=4500, and pp_ucode() is found
* below. Please refer there for function explanation.
if !pp_valdate() .AND. pp_exptype()#"N"
clear
@ 2,0 say "The date and time is still incorrect. Please call technical support"
@ 3,0 say "for assistance. Code entry #: "+ltrim(str(pp_cenum()))+" Date: "+dtoc(date())
propl0=4500
get_code=0
@ 5,0 say "Enter code: " get get_code picture "@Z"
read
if pp_ucode(get_code)=5
pp_upddate()
pp_getvar() && get new values since they just changed
else
clear
cancel
endif
endif
* Set up some global flags
* Is this an execution limit version? See below for details.
exe_limit=( pp_exptype() = "E" )
* Here is some basic screen setup
if iscolor()
setcolor("w+/b")
else
setcolor("w")
endif
clear
set scoreboard off
@ 0,0 to 24,79
@ 1,13 say "P R O T E C T I O N P L U S F O R C L I P P E R"
* The pp_serial function contains the serial number either hard coded in
* the EXE file (by the user-control program) or in the control file.
* The pp_compno function is used optionally to give you a computer "number."
* When the user first calls you to be unlocked (if copy protection is used),
* you enter the number that appears on his screen into the customer record.
* If the user calls and says that his control file was corrupted and you
* need to send another one, when he calls back to unlock the new control
* file and this number is DIFFERENT, he is trying to fool you and install
* your software on another computer. This adds another level of security
* when the user "acts" stupid!
@ 4,2 say " Serial: "+pp_serial()+"/"+ltrim(str(pp_compno()))
* The pp_cenum function returns a code entry number. This number is
* random, and leads to the ability to secure hidden procedures in your
* source code and only allow user access when he is online with you.
* Protection Plus gives you ten hidden procedures. For example, say
* you have a password function in your application and your user forgets
* his password. He can call you, tell you the code entry number on the
* screen, and you can run the decoder routine (in the host program) with
* his code entry number as a parameter, and instantly tell him a number to
* type in response to a special prompt, and the password check is
* overwritten. He can then run the program, go to the password change
* function, and create a new password for future use. Keep in mind, that
* the code entry number is random, but the actual code to enter in the
* special prompt changes EVERY DAY according to that number. It would
* be nearly impossible to break the code, eliminating the possiblity of
* one user calling another user and using unauthorized codes. There are
* so many possiblities available for this section - see the manual text
* file or brochure for more information
@ 5,2 say "Code entry: "+ltrim(str(pp_cenum()))
* The following line is to "fix" the code entry number to 4500 ONLY FOR
* THE PURPOSE OF THIS DEMO PROGRAM. This is so that you can test out the
* code entry section of this demo. Your application will let pp_cenum set
* the code entry number. Run the unlock decoder routine with 4500 as a
* parameter to find out the codes for today.
propl0=4500
@ 4,64 say "Date: "+dtoc(date())
@ 5,59 say "Last used: "+dtoc(propl17) && last date used
@ 6,70 say propl18 && last time used
@ 7,61 say if(!empty(propl10),"Expires: "+dtoc(propl10),"") && expiration date
@ 8,24 say "Protection plus sample program!"
@ 10,22 say "This is your power-up screen routine"
* The following set key sequence allows for the code entry to be a
* hot key away from a password retrieval function or inkey(0) sequence.
set key -4 to ucode
password=space(8)
do while empty(password) .AND. !lastkey()=27
@ 20,28 clear to 20,60
@ 20,30 say "Password: " get password picture "@!"
read
enddo
set key -4 to
* write your own code here to test password and continue program if ok
if password#"PROPLUS "
pp_upddate()
set color to
clear
@ 2,0 say "Incorrect password entered, program aborted!"
@ 4,0 say ""
cancel
endif
* At this point, the program is allowed to continue. This is where you
* would stick the first "DO" command to execute your main menu or whatever
* you do next. For this demo, we have created a menu that allows for
* different functions. The functions on this menu allow you to further
* check out the Protection Plus library.
* The first thing to do is every time the main menu is accessed, the
* execution counter should be incremented if the expire type is set to
* execution limit. The value of EXE_LIMIT was found in the beginning of
* the program.
if exe_limit
pp_advect()
endif
clear
@ 0,0 to 24,79
@ 1,13 say "P R O T E C T I O N P L U S F O R C L I P P E R"
choice=1
@ 7,3 to 12,20
do while .T.
@ 2,21 clear to 23,78
@ 7,7 say "MAIN MENU"
@ 8,5 prompt "View variables"
@ 9,5 prompt "Edit variables"
@ 10,5 prompt "Macro entry "
@ 11,5 prompt "Exit program "
@ 6,29 say "This is the Protection Plus sample program MAIN"
@ 7,29 say "MENU. There are some choices here that allow"
@ 8,29 say "you to test out some of the features of the "
@ 9,29 say "Protection Plus library. Look the the source"
@ 10,29 say "file SAMPLE.PRG for a full description of all"
@ 11,29 say "the library functions used in this sample"
@ 12,29 say "program. It is EASY to implement the source"
@ 13,29 say "changes in your own existing applications!"
menu to choice
do case
case choice=1
@ 2,21 clear to 23,78
* This assumes that pp_getvar() has already been run. In this
* sample program, it was run in the very beginning. This is a
* very lacking way to allow the user to change internal values.
* This could very easily be beefed-up a bit.
@ 5,34 SAY "Company: "+propl1
@ 6,34 SAY " Name: "+propl2
@ 7,34 SAY "Address: "+propl3
@ 8,34 SAY " City: "+propl4+", "+propl5+" "+propl6
@ 9,34 SAY " Phone: "+propl7
@ 10,34 SAY "Product: "+propl8
@ 11,34 SAY "Serial#: "+propl9
@ 12,34 SAY "Expires: "+dtoc(propl10)
@ 13,34 SAY "Company: "+propl12
@ 14,34 SAY "Address: "+propl13
@ 15,34 SAY " "+propl14
@ 16,34 SAY " Phone: "+propl15
@ 17,34 SAY " FAX: "+propl16
@ 18,34 SAY "Last "+dtoc(propl17)
@ 19,34 SAY " Used: "+propl18
@ 21,34 say "Press any key..."
inkey(0)
case choice=2
@ 2,21 clear to 23,78
* This assumes that pp_getvar() has already been run. In this
* sample program, it was run in the very beginning.
@ 5,34 SAY "Company: " get propl1
@ 6,34 SAY " Name: " get propl2
@ 7,34 SAY "Address: " get propl3
@ 8,34 SAY " City: " get propl4
@ 8,61 get propl5
@ 8,65 get propl6
@ 9,34 SAY " Phone: " get propl7
@ 10,34 SAY "Product: " get propl8
@ 11,34 SAY "Serial#: " get propl9
@ 12,34 SAY "Expires: " get propl10
@ 13,34 SAY "Company: " get propl12
@ 14,34 SAY "Address: " get propl13
@ 15,34 SAY " " get propl14
@ 16,34 SAY " Phone: " get propl15
@ 17,34 SAY " FAX: " get propl16
@ 18,34 SAY "Last " get propl17
@ 19,34 SAY " Used: " get propl18
read
if lastkey()#27
pp_savepp()
endif
case choice=3
do while lastkey()#27
@ 2,21 clear to 23,78
string=space(50)
@ 10,30 say "Enter macro string:" get string picture "@S20"
@ 11,30 say "<ESC> to abort"
read
if lastkey()#27
@ 15,30 say "Result:"
@ 15,38 say &string
@ 17,30 say "Press any key.."
inkey(0)
endif
enddo
otherwise
exit_program()
endcase
enddo .T.
return
* A function to clean up screen and update the last used date and time is
* recommended. The last used date and time should be updated upon exiting
* because if the user keeps setting back the clock, it would be impossible to
* avoid the narrowing window. If he uses the program for an hour every day,
* eventually, no matter how much he changes the date and time, will not
* be able to access the program. This occurs provided that you run the
* check date function pp_valdate upon entry.
FUNCTION exit_program
pp_upddate()
set color to
clear
cancel
return .T.
* This function you create to get the secret number after the user
* signals the code entry key sequence, whatever you define. For the purposes
* of this demo, only the result routine number is printed on the screen.
* In your application, you could set up a set of case statements for
* each value (1-10) to carry out your routines. A zero is returned if
* an invalid value was entered
* The program can execute a function and continue with the program or
* execute a function and cancel to dos. You have complete control! All of
* these functions drop to dos after executing.
FUNCTION ucode
PRIVATE _routine
clear gets
get_code=0
@ 20,28 say "Enter code: " get get_code picture "@Z"
read
if lastkey()=27
retu .T.
endif
_routine=pp_ucode(get_code)
set color to
clear
do case
case _routine=1 && unlock application
if pp_unlock()
@ 2,0 say "Application unlocked..."
endif
case _routine=2 && advance payment date
if pp_nexptype("P",pp_npdate(date(),20))
@ 2,0 say "Application payment expire date extended to "+dtoc(pp_npdate(date(),20))
endif
case _routine=3 && kill protection from disk
if pp_killprot()
@ 2,0 say "Protection erased!"
endif
case _routine=4
if pp_nexptype("D",ctod("4/10/91"))
@ 2,0 say "Application demo expire date set to 4/1/91"
endif
case _routine=10 && write copy protection file
pp_copywrite()
case _routine=0 && error
retu .F.
otherwise && anything else
@ 2,0 say "Routine # to be executed ="+str(_routine)
endcase
@ 4,0 say ""
exit_program()
return .T.